<ion-header>
    <ion-toolbar>
        <ion-title>
            <h1>{{ pageInstance?.lesson?.name }}</h1>
        </ion-title>
        <ion-buttons slot="end">
            <ion-button fill="clear" (click)="closeModal()" [ariaLabel]="'core.close' | translate">
                <ion-icon slot="icon-only" name="fas-xmark" aria-hidden="true" />
            </ion-button>
        </ion-buttons>
    </ion-toolbar>
</ion-header>
<ion-content class="addon-mod_lesson-menu-modal">
    <nav>
        @if (pageInstance) {
            <ion-list>
                <!-- Media file. -->
                @if (pageInstance.mediaFile) {
                    <ion-item-divider>
                        <ion-label>
                            <h2>{{ 'addon.mod_lesson.linkedmedia' | translate }}</h2>
                        </ion-label>
                    </ion-item-divider>
                    <core-file [file]="pageInstance.mediaFile" [component]="pageInstance.component"
                        [componentId]="pageInstance.lesson?.coursemodule" />
                }

                <!-- Lesson menu. -->
                @if (pageInstance.displayMenu) {

                    <ion-item-divider>
                        <ion-label>
                            <h2>{{ 'addon.mod_lesson.lessonmenu' | translate }}</h2>
                        </ion-label>
                    </ion-item-divider>
                    @if (pageInstance.loadingMenu) {
                        <ion-item class="ion-text-center">
                            <ion-label>
                                <ion-spinner [attr.aria-label]="'core.loading' | translate" />
                            </ion-label>
                        </ion-item>
                    } @else {
                        <div>
                            <ng-container *ngFor="let page of pageInstance.lessonPages">
                                @if (page.display && page.displayinmenublock) {
                                    <ion-item class="ion-text-wrap" (click)="loadPage(page.id)"
                                        [attr.aria-current]="!pageInstance.eolData && pageInstance.currentPage === page.id ? 'page' : 'false'"
                                        button [detail]="true">
                                        <ion-label>
                                            <core-format-text [text]="page.title" contextLevel="module" [courseId]="pageInstance.courseId"
                                                [contextInstanceId]="pageInstance.lesson?.coursemodule" />
                                        </ion-label>
                                    </ion-item>
                                }
                            </ng-container>
                        </div>
                    }

                }
            </ion-list>
        }
    </nav>
</ion-content>
